import axios from './axios'
import qs from 'qs'

export function getQuotationNo() {
    return axios.get('/spare_quotation/manage/get_spare_quotation_no.do').then(res => Promise.resolve(res.data), err => Promise.reject(err))
}

export function saveQuotation({quotationNo, quotationDateStr, quotationBy, customer, quotationDetail, address, contact, phone, discount, ppn, shipment, shipmentFee, price, id, coefficient}) {
    return axios.post('/spare_quotation/manage/save_spare_quotation.do',
        qs.stringify({
            quotationNo,
            quotationDateStr,
            quotationBy,
            customer,
            quotationDetail,
            address,
            contact,
            phone,
            discount,
            ppn,
            shipment,
            shipmentFee,
            price,
            id,
            coefficient
        }))
        .then(res => Promise.resolve(res.data))
}

export function getQuotationList() {
    return axios.get('/spare_quotation/manage/get_spare_quotation_list.do').then(res => Promise.resolve(res.data), err => Promise.reject(err))
}

export function getQuotationDetail(quotationId) {
    return axios.post('/spare_quotation/manage/get_spare_quotation_detail.do', qs.stringify({quotationId})).then(res => Promise.resolve(res.data), err => Promise.reject(err))
}

export function confirmQuotation({quotationNo, quotationDateStr, quotationBy, customer, quotationDetail, address, contact, phone, discount, ppn, shipment, shipmentFee, price, customerPo, id, coefficient}) {
    return axios.post('/spare_quotation/manage/confirm_spare_quotation.do',
        qs.stringify({
            quotationNo,
            quotationDateStr,
            quotationBy,
            customer,
            quotationDetail,
            address,
            contact,
            phone,
            discount,
            ppn,
            shipment,
            shipmentFee,
            price,
            customerPo,
            id,
            coefficient
        }))
        .then(res => Promise.resolve(res.data))
}


export function getInformationList() {
    return axios.get('/customer_information_collection/select_information.do').then(res => Promise.resolve(res.data))
}

export function collectInfo({
                                recordInformation,
                                companyName,
                                contacts,
                                contactNumber,
                                address,
                                createTime,
                                recordTitle
                            }) {
    const data = qs.stringify({
        recordInformation,
        companyName,
        contacts,
        contactNumber,
        address,
        createTime,
        recordTitle
    });
    return axios.post('/customer_information_collection/save_information.do', data).then(res => Promise.resolve(res.data));
}


export function getSalesOrderList() {
    return axios.post('/spare_sale_order/manage/get_spare_sale_order_list.do').then(res => Promise.resolve(res.data))
}

export function getSalesOrderDetail(id) {
    return axios.post('/spare_sale_order/manage/get_spare_sale_order_detail.do', qs.stringify({id})).then(res => Promise.resolve(res.data))
}


//  展示列表
export function showProcessList() {
    return axios.get('/sales_process/manage/show_process_list.do').then(res => Promise.resolve(res.data))
}

//  合同评价表的详细信息
export function showProcessDetail(id) {
    return axios.post('/sales_process/manage/show_process_detail.do', qs.stringify({id})).then(res => Promise.resolve(res.data))
}

//  新增销售信息
export function addSalesProcess({
                                    submitDateStr, salesMan, customerName, customerAddress, contactInformation, email, website, operationalLocation, belongIndustry, customerMainBusiness, projectSite, projectDescription,
                                    operatingEquipment, taxCard, financialPosition, customerAdvantage, customerPotential, deliveryDateStr, deliveryPlace, paymentMethod, inquiryEquipment, inquiryParts, inquiryService, remarks, remarksSecond
                                }) {
    return axios.post('/sales_process/manage/add_sales_process.do', qs.stringify({
        submitDateStr,
        salesMan,
        customerName,
        customerAddress,
        contactInformation,
        email,
        website,
        operationalLocation,
        belongIndustry,
        customerMainBusiness,
        projectSite,
        projectDescription,
        operatingEquipment,
        taxCard,
        financialPosition,
        customerAdvantage,
        customerPotential,
        deliveryDateStr,
        deliveryPlace,
        paymentMethod,
        inquiryEquipment,
        inquiryParts,
        inquiryService,
        remarks,
        remarksSecond
    })).then(res => Promise.resolve(res.data))
}

//  修改销售信息
export function updateSalesProcess({
                                       submitDateStr, salesMan, customerName, customerAddress, contactInformation, email, website, operationalLocation, belongIndustry, customerMainBusiness, projectSite, projectDescription,
                                       operatingEquipment, taxCard, financialPosition, customerAdvantage, customerPotential, deliveryDateStr, deliveryPlace, paymentMethod, inquiryEquipment, inquiryParts, inquiryService, remarks, remarksSecond, id
                                   }) {
    return axios.post('/sales_process/manage/update_sales_process.do', qs.stringify({
        submitDateStr,
        salesMan,
        customerName,
        customerAddress,
        contactInformation,
        email,
        website,
        operationalLocation,
        belongIndustry,
        customerMainBusiness,
        projectSite,
        projectDescription,
        operatingEquipment,
        taxCard,
        financialPosition,
        customerAdvantage,
        customerPotential,
        deliveryDateStr,
        deliveryPlace,
        paymentMethod,
        inquiryEquipment,
        inquiryParts,
        inquiryService,
        remarks,
        remarksSecond,
        id
    })).then(res => Promise.resolve(res.data))
}


//  新增报价信息
export function addQuotationProcess({
                                        firstDeliveryDateStr, firstDeliveryPlace, firstPaymentMethod, firstInquiryEquipment, firstInquiryParts, firstInquiryService, firstQuoter, firstAuditor, firstDateStr, firstEquipmentPrice, firstPartsPrice, firstServicePrice, firstRemarks,
                                        secondDeliveryDateStr, secondDeliveryPlace, secondPaymentMethod, secondInquiryEquipment, secondInquiryParts, secondInquiryService, secondQuoter, secondAuditor, secondDateStr, secondEquipmentPrice, secondPartsPrice, secondServicePrice, secondRemarks,
                                        thirdDeliveryDateStr, thirdDeliveryPlace, thirdPaymentMethod, thirdInquiryEquipment, thirdInquiryParts, thirdInquiryService, thirdQuoter, thirdAuditor, thirdDateStr, thirdEquipmentPrice, thirdPartsPrice, thirdServicePrice, thirdRemarks, salesProcessId
                                    }) {
    return axios.post('/quotation_process/manage/add_quotation_process.do', qs.stringify({
        firstDeliveryDateStr,
        firstDeliveryPlace,
        firstPaymentMethod,
        firstInquiryEquipment,
        firstInquiryParts,
        firstInquiryService,
        firstQuoter,
        firstAuditor,
        firstDateStr,
        firstEquipmentPrice,
        firstPartsPrice,
        firstServicePrice,
        firstRemarks,
        secondDeliveryDateStr,
        secondDeliveryPlace,
        secondPaymentMethod,
        secondInquiryEquipment,
        secondInquiryParts,
        secondInquiryService,
        secondQuoter,
        secondAuditor,
        secondDateStr,
        secondEquipmentPrice,
        secondPartsPrice,
        secondServicePrice,
        secondRemarks,
        thirdDeliveryDateStr,
        thirdDeliveryPlace,
        thirdPaymentMethod,
        thirdInquiryEquipment,
        thirdInquiryParts,
        thirdInquiryService,
        thirdQuoter,
        thirdAuditor,
        thirdDateStr,
        thirdEquipmentPrice,
        thirdPartsPrice,
        thirdServicePrice,
        thirdRemarks,
        salesProcessId
    })).then(res => Promise.resolve(res.data))
}

// 修改报价信息
export function updateQuotationProcess({
                                           firstDeliveryDateStr, firstDeliveryPlace, firstPaymentMethod, firstInquiryEquipment, firstInquiryParts, firstInquiryService, firstQuoter, firstAuditor, firstDateStr, firstEquipmentPrice, firstPartsPrice, firstServicePrice, firstRemarks,
                                           secondDeliveryDateStr, secondDeliveryPlace, secondPaymentMethod, secondInquiryEquipment, secondInquiryParts, secondInquiryService, secondQuoter, secondAuditor, secondDateStr, secondEquipmentPrice, secondPartsPrice, secondServicePrice, secondRemarks,
                                           thirdDeliveryDateStr, thirdDeliveryPlace, thirdPaymentMethod, thirdInquiryEquipment, thirdInquiryParts, thirdInquiryService, thirdQuoter, thirdAuditor, thirdDateStr, thirdEquipmentPrice, thirdPartsPrice, thirdServicePrice, thirdRemarks, salesProcessId, id
                                       }) {
    return axios.post('/quotation_process/manage/update_quotation_process.do', qs.stringify({
        firstDeliveryDateStr,
        firstDeliveryPlace,
        firstPaymentMethod,
        firstInquiryEquipment,
        firstInquiryParts,
        firstInquiryService,
        firstQuoter,
        firstAuditor,
        firstDateStr,
        firstEquipmentPrice,
        firstPartsPrice,
        firstServicePrice,
        firstRemarks,
        secondDeliveryDateStr,
        secondDeliveryPlace,
        secondPaymentMethod,
        secondInquiryEquipment,
        secondInquiryParts,
        secondInquiryService,
        secondQuoter,
        secondAuditor,
        secondDateStr,
        secondEquipmentPrice,
        secondPartsPrice,
        secondServicePrice,
        secondRemarks,
        thirdDeliveryDateStr,
        thirdDeliveryPlace,
        thirdPaymentMethod,
        thirdInquiryEquipment,
        thirdInquiryParts,
        thirdInquiryService,
        thirdQuoter,
        thirdAuditor,
        thirdDateStr,
        thirdEquipmentPrice,
        thirdPartsPrice,
        thirdServicePrice,
        thirdRemarks,
        salesProcessId,
        id
    })).then(res => Promise.resolve(res.data))
}


// 新增支付信息
export function addPaymentProcess({
                                      contractualProduct, productDeliveryDateStr, freight, DeliveryPlace, otherFreight, Commission, equipment, unitPriceExcludesTax, parts, totalTaxFreePrice, service, serviceTotalTaxFreePrice, netPrice, netPriceFinancialPaymentMethod, taxation, taxationFinancialPaymentMethod, downPayments,
                                      downPaymentsFinancialPaymentMethod, tailMoney, tailMoneyPaymentsFinancialPaymentMethod, payMonthly, payDate, firstMonthlyPayment, payMonthlyIN, totalTaxIncludedPrice, contractNo, contractMaking, contractMakingDateStr, contractAudit, contractAuditDateStr, financialSignature, financialSignatureDateStr, salesProcessId
                                  }) {
    return axios.post('/payment_process/manage/add_payment_process.do', qs.stringify({
        contractualProduct,
        productDeliveryDateStr,
        freight,
        DeliveryPlace,
        otherFreight,
        Commission,
        equipment,
        unitPriceExcludesTax,
        parts,
        totalTaxFreePrice,
        service,
        serviceTotalTaxFreePrice,
        netPrice,
        netPriceFinancialPaymentMethod,
        taxation,
        taxationFinancialPaymentMethod,
        downPayments,
        downPaymentsFinancialPaymentMethod,
        tailMoney,
        tailMoneyPaymentsFinancialPaymentMethod,
        payMonthly,
        payDate,
        firstMonthlyPayment,
        payMonthlyIN,
        totalTaxIncludedPrice,
        contractNo,
        contractMaking,
        contractMakingDateStr,
        contractAudit,
        contractAuditDateStr,
        financialSignature,
        financialSignatureDateStr,
        salesProcessId
    })).then(res => Promise.resolve(res.data))
}

//  修改支付信息
export function updatePaymentProcess({
                                         contractualProduct, productDeliveryDateStr, freight, DeliveryPlace, otherFreight, Commission, equipment, unitPriceExcludesTax, parts, totalTaxFreePrice, service, serviceTotalTaxFreePrice, netPrice, netPriceFinancialPaymentMethod, taxation, taxationFinancialPaymentMethod, downPayments,
                                         downPaymentsFinancialPaymentMethod, tailMoney, tailMoneyPaymentsFinancialPaymentMethod, payMonthly, payDate, firstMonthlyPayment, payMonthlyIN, totalTaxIncludedPrice, contractNo, contractMaking, contractMakingDateStr, contractAudit, contractAuditDateStr, financialSignature, financialSignatureDateStr, salesProcessId, id
                                     }) {
    return axios.post('/payment_process/manage/update_payment_process.do', qs.stringify({
        contractualProduct,
        productDeliveryDateStr,
        freight,
        DeliveryPlace,
        otherFreight,
        Commission,
        equipment,
        unitPriceExcludesTax,
        parts,
        totalTaxFreePrice,
        service,
        serviceTotalTaxFreePrice,
        netPrice,
        netPriceFinancialPaymentMethod,
        taxation,
        taxationFinancialPaymentMethod,
        downPayments,
        downPaymentsFinancialPaymentMethod,
        tailMoney,
        tailMoneyPaymentsFinancialPaymentMethod,
        payMonthly,
        payDate,
        firstMonthlyPayment,
        payMonthlyIN,
        totalTaxIncludedPrice,
        contractNo,
        contractMaking,
        contractMakingDateStr,
        contractAudit,
        contractAuditDateStr,
        financialSignature,
        financialSignatureDateStr,
        salesProcessId,
        id
    })).then(res => Promise.resolve(res.data))
}


//  新增财务部门确认信息
export function addFinanceDepartmentConfirm({
                                                financeDownPayments, financeDownPaymentsDateStr, financeTailMoney, financeTailMoneyDateStr, tailMoneyCheck, tailMoneyCheckDate, paymentStatus, financeDeliveryDateStr, costAccounting, fob, of, bm, hd, totalCost, gsrossInterestRateTop,
                                                gsrossInterestRateBottom, gsrossInterestRate, apportionedCost, awardBase, paymentBonuses, netProfitOne, netProfitTwo, netProfitThree, netProfitFour, netProfit, explainDetail, orderMaking, examine, finance, generalManager, chiefInspector, filling, orderMakingDateStr,
                                                examineDateStr, financeDateStr, generalManagerDateStr, chiefInspectorDateStr, filingDateStr, salesProcessId
                                            }) {
    return axios.post('/finance_department_confirm/manage/add_finance_department_confirm.do', qs.stringify({
        financeDownPayments,
        financeDownPaymentsDateStr,
        financeTailMoney,
        financeTailMoneyDateStr,
        tailMoneyCheck,
        tailMoneyCheckDate,
        paymentStatus,
        financeDeliveryDateStr,
        costAccounting,
        fob,
        of,
        bm,
        hd,
        totalCost,
        gsrossInterestRateTop,
        gsrossInterestRateBottom,
        gsrossInterestRate,
        apportionedCost,
        awardBase,
        paymentBonuses,
        netProfitOne,
        netProfitTwo,
        netProfitThree,
        netProfitFour,
        netProfit,
        explainDetail,
        orderMaking,
        examine,
        finance,
        generalManager,
        chiefInspector,
        filling,
        orderMakingDateStr,
        examineDateStr,
        financeDateStr,
        generalManagerDateStr,
        chiefInspectorDateStr,
        filingDateStr,
        salesProcessId
    })).then(res => Promise.resolve(res.data))
}

//  修改财务部门信息
export function updateFinanceDepartmentConfirm({
                                                   financeDownPayments, financeDownPaymentsDateStr, financeTailMoney, financeTailMoneyDateStr, tailMoneyCheck, tailMoneyCheckDate, paymentStatus, financeDeliveryDateStr, costAccounting, fob, of, bm, hd, totalCost, gsrossInterestRateTop,
                                                   gsrossInterestRateBottom, gsrossInterestRate, apportionedCost, awardBase, paymentBonuses, netProfitOne, netProfitTwo, netProfitThree, netProfitFour, netProfit, explainDetail, orderMaking, examine, finance, generalManager, chiefInspector, filling, orderMakingDateStr,
                                                   examineDateStr, financeDateStr, generalManagerDateStr, chiefInspectorDateStr, filingDateStr, salesProcessId, id
                                               }) {
    return axios.post('/finance_department_confirm/manage/update_finance_department_confirm.do', qs.stringify({
        financeDownPayments,
        financeDownPaymentsDateStr,
        financeTailMoney,
        financeTailMoneyDateStr,
        tailMoneyCheck,
        tailMoneyCheckDate,
        paymentStatus,
        financeDeliveryDateStr,
        costAccounting,
        fob,
        of,
        bm,
        hd,
        totalCost,
        gsrossInterestRateTop,
        gsrossInterestRateBottom,
        gsrossInterestRate,
        apportionedCost,
        awardBase,
        paymentBonuses,
        netProfitOne,
        netProfitTwo,
        netProfitThree,
        netProfitFour,
        netProfit,
        explainDetail,
        orderMaking,
        examine,
        finance,
        generalManager,
        chiefInspector,
        filling,
        orderMakingDateStr,
        examineDateStr,
        financeDateStr,
        generalManagerDateStr,
        chiefInspectorDateStr,
        filingDateStr,
        salesProcessId,
        id
    })).then(res => Promise.resolve(res.data))
}

